/*
 *返回顶部必须把传入click属性,对应的值为调用此组件的this.refs.xx
*/
'use strict';
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    PixelRatio,
    Text,
    View,
	Image,
	TouchableWithoutFeedback
} from 'react-native';
import css from './common_css.js'
import dp from './pxToDp.js'
class BackTop extends Component{
    constructor(props) {
      	super(props);
      	this.state = {

      	};
    }
    render(){
		return(
			<TouchableWithoutFeedback
				onPress={()=>{
					console.log(this.props.click)
					this.props.click.scrollTo({x:0,y:0,animated:false})
				}}
				>
				<View style={[s.position,s.img]}>
					<Image
						source={require('../image/ic_back_top.png')}
						style={[s.img]}
						resizeMode='contain'
						></Image>
				</View>
			</TouchableWithoutFeedback>
		)
    }
}

var style={
	position:{
		position:'absolute',
		bottom:20,
		right:15,
	},
	img:{
		width:dp(45),
		height:45,
	}
}
for(var n in style){
	css[n]=style[n]
}
const s = StyleSheet.create(css);

module.exports=BackTop;
